package cn.itcast.model.bean

/**
 * Hbase元数据的封装类
 */
case class HBaseMeta(
                      inType: String, // 当前数据源的类型
                      zkHosts: String, // zk主机地址
                      zkPort: String, // zk端口号
                      hbaseTable: String, // HBase的表名字
                      family: String, // 表的列簇名字
                      selectFields: String // 我们需要选择的列: 多个列用","进行分隔
                    )

object HBaseMeta{
  //定义map中的变量的名称,方便全局使用
  val INTYPE = "inType"
  val ZKHOSTS = "zkHosts"
  val ZKPORT = "zkPort"
  val HBASETABLE = "hbaseTable"
  val FAMILY = "family"
  val SELECTFIELDS = "selectFields"


  /**
   * 根据Map直接生成HBaseMeta对象
   * @param map
   * @return
   */
  def apply(map: Map[String, String]): HBaseMeta = {
    HBaseMeta(
      map.getOrElse(HBaseMeta.INTYPE, ""),
      map.getOrElse(HBaseMeta.ZKHOSTS, ""),
      map.getOrElse(HBaseMeta.ZKPORT, ""),
      map.getOrElse(HBaseMeta.HBASETABLE, ""),
      map.getOrElse(HBaseMeta.FAMILY, ""),
      map.getOrElse(HBaseMeta.SELECTFIELDS, "")
    )
  }
}
